package com.wn32.main.demo11;

import com.wn32.main.myannos.MyAnno;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException {
        System.out.println("请输入类名");
        String path ="com.wn32.main.demo11." + new Scanner(System.in).next();
//        System.out.println("输入方法名");
//        String methodName = new Scanner(System.in).next();
        Object obj = Class.forName(path).newInstance();
        Annotation[] annotations = obj.getClass().getDeclaredAnnotations();
        MyAnno myAnno = obj.getClass().getDeclaredAnnotation(MyAnno.class);
        String value = myAnno.value();
        int age = myAnno.age();
        System.out.println("value="+value +";age="+age);
        for (Annotation annotation : annotations) {
            System.out.println(annotation.annotationType().getName());
        }
//        Method[] methods = obj.getClass().getDeclaredMethods();
//        for (Method method : methods) {
//            if(method.getName().equals(methodName)){
//                method.invoke(obj);
//            }
//        }
    }
}
